package com.qishao.oss_service.controller;

import com.alibaba.druid.util.StringUtils;
import com.qishao.oss_service.ossService.OssService;
import com.qishao.service_base.reponse.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/oss")
@CrossOrigin
public class OssController {


    @Autowired
    private OssService ossService;


    @PostMapping("/uploadFile")
    public Response uploadFile(MultipartFile file,String fileType){
        String url = ossService.UploadDocument(file, fileType);
        if (StringUtils.isEmpty(url)) return Response.error();
        return Response.ok().data("url",url);

    }


    @PostMapping("/test")
    public Response test(){
        return Response.ok().data("test","feign调用");
    }

}
